package com.quan.api.oms;

import com.quan.commons.core.bean.R;
import com.quan.commons.core.biz.support.MyBaseController;
import com.quan.commons.core.utils.PageUtils;
import com.quan.mall.commons.vo.OmsOrderReturnApplyVo;
import com.quan.mall.service.OmsOrderReturnApplyService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 订单-退货申请
 * @author yhaoquan
 * @email yhaoquan@163.com
 * @date 2021-03-09 17:22:38
 */
@Slf4j
@Api(tags = "订单-退货申请")
@RestController
@RequestMapping("/api/mall/omsorderreturnapply")
public class ApiOmsOrderReturnApplyController extends MyBaseController {

    @Autowired
    private OmsOrderReturnApplyService service;

    /**
     * 退款申请列表
     * @param vo
     * @return
     */
    @GetMapping(value = "list")
    public Object list(OmsOrderReturnApplyVo vo) {
        List<OmsOrderReturnApplyVo> list = this.service.queryList(new PageUtils(request), vo);
        return R.ok().put("data", list);
    }

    /**
     * 查询收货退款详情
     * @param id
     * @return
     */
    @GetMapping("/getOrderReturnApplyInfo/{id}")
    public R getOrderReturnApplyInfo(@PathVariable("id") Long id) {
        OmsOrderReturnApplyVo omsOrder = this.service.getOrderReturnApplyInfo(id);
        return R.ok().put("data", omsOrder);
    }


    /**
     * 会员申请退款
     * @param vo
     * @return
     */
    @PostMapping("/apply")
    public R apply(@RequestBody OmsOrderReturnApplyVo vo) {
        return R.ok().put("data", this.service.apply(vo));
    }


    /**
     * 会员提交快递信息
     * @param vo
     * @return
     */
    @PostMapping("/submitExpress")
    public R submitExpress(@RequestBody OmsOrderReturnApplyVo vo) {
        this.service.submitExpress(vo);
        return R.ok();
    }

}
